import 'package:dio/dio.dart';
import 'package:get/get_connect/http/src/response/response.dart';

import 'auth/ApiBase.dart';
import 'auth/AuthBase.dart';
import 'dio/BaseModel.dart';
import 'dio/DioClient.dart';


class MessageApi extends ApiBase {

  //消息列表
  Future<BaseModel> messageList({
    int? userId, int? deviceType, int? alarmType,
    String? startDate, String? endDate,
    String? messageName,
    int? pageNum,
    int? pageSize,
  }) async {

    // 构建请求参数
    Map<String, dynamic> queryParameters = {};

    queryParameters['userId'] = userId;
    queryParameters['pageNum'] = pageNum;
    queryParameters['pageSize'] = pageSize;
    if (deviceType != null) {
      queryParameters['deviceType'] = deviceType;
    }
    if (alarmType != null) {
      queryParameters['alarmType'] = alarmType;
    }

    if (startDate != null) {
      queryParameters['startDate'] = startDate;
    }
    if (endDate != null) {
      queryParameters['endDate'] = endDate;
    }

    if (messageName != null) {
      queryParameters['messageName'] = messageName;
    }
    print('asdfasdf');
    print(queryParameters);

    BaseModel response = await DioClient().doDio(
        "/message/list",
        method: HTTPMethod.get,
        queryParameters: queryParameters, // 传递查询参数
        loading: true
    );

    return response;
  }





  Future<BaseModel> getRouters(List<int> readList) async {

    // 设置请求选项，指定内容类型为 JSON
    Options options = Options(
      contentType: Headers.jsonContentType,
    );

    BaseModel response = await DioClient().doDio(
      "/message/readList",
      method: HTTPMethod.post,
      data: readList,
      options: options, // 传递选项参数
      loading: true,
    );

    return response;
  }












}


























